package com.baize.cpdepus.controller;

import com.baize.cpdepus.common.R;
import com.baize.cpdepus.entity.Order;
import com.baize.cpdepus.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * @param id 买家id查询订单
     * @买家的信息查询
     */
    @GetMapping("getSeller")
    public R getSeller(Integer id) {
        return R.success(orderService.sellerIdAll(id));
    }

    /**
     * @param id 卖家id查询订单
     * @卖家的信息查询
     */
    @GetMapping("getPurchaser")
    public R getPurchaser(Integer id) {
        return R.success(orderService.purchaserIdAll(id));
    }

    @PostMapping("createOrder")
    public R createOrder(Order order) {
        orderService.add(order);
        return R.success("");//生成订单在返回订单信息
    }
}
